package cn.itcast.hotel.mq;

import cn.itcast.hotel.constants.HotelMqConstants;
import cn.itcast.hotel.service.IHotelService;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author 嘉德罗斯
 * @date 2021/11/13
 */
@Component
public class HotelListener {

    @Autowired
    private IHotelService iHotelService;

    @RabbitListener(queues = HotelMqConstants.INSERT_QUEUE_NAME)
    public void listenHotelInsertOrUpdate(Long id){
        iHotelService.insertById(id);
    }

    @RabbitListener(queues = HotelMqConstants.DELETE_QUEUE_NAME)
    public void listenHotelDelete(Long id){
        iHotelService.deleteById(id);
    }
}
